package com.engineering.elink.service.impl.file;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.engineering.elink.common.util.BaseCo;
import com.engineering.elink.common.util.ErrorType;
import com.engineering.elink.common.util.JSONUtil;
import com.engineering.elink.common.util.Pagination;
import com.engineering.elink.dao.file.FileMapper;
import com.engineering.elink.service.file.FileService;

@Service
public class FileServiceImpl implements FileService{
	@Autowired
	private FileMapper fileMapper;

	@Override
	@Cacheable(value = "fileCache") 
	public Map<String, Object> selectList(BaseCo co) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", fileMapper.selectList(co));
		map.put("pagination", new Pagination(co, fileMapper.selectCount(co)));
		return JSONUtil.getJSON(ErrorType.SUCCESS, map);
	}

	@Override
	public int selectCount() {
		return fileMapper. selectCount();
	}
}
